package com.maimang.platform.crm.service;

import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse;
import com.dingtalk.api.response.OapiSsoGetuserinfoResponse;

/**
 * @author Rocky
 * @version 1.0.0
 * @classname DingTalkLoginService
 * @description <br>钉钉后台登录service</br>
 * @date 2019-09-30 10:20
 * @email jintaozhao@qq.com
 */
public interface DingTalkLoginService {


	/**
	 * 获取应用后台免登的accessToken
	 *
	 * @param corpid     企业Id
	 * @param corpsecret 专属的SSOSecret
	 * @return
	 * @throws Exception
	 */
	String getToken(String corpid, String corpsecret) throws Exception;

	/**
	 * 获取应用管理员的身份信息
	 *
	 * @param accessToken 此token不同于一般的accessToken，需要调用获取微应用管理员免登需要的AccessToken
	 * @param code        通过Oauth认证给URL带上的CODE
	 * @return
	 * @throws Exception
	 */
	OapiSsoGetuserinfoResponse getUserInfo(String accessToken, String code) throws Exception;

	/**
	 * 获取应用管理员的身份信息
	 *
	 * @param code 通过Oauth认证给URL带上的CODE
	 * @return
	 * @throws Exception
	 */
	OapiSsoGetuserinfoResponse getUserInfo(String code) throws Exception;


	/**
	 * 获取用户userid
	 *
	 * @param code 免登授权码
	 * @return
	 * @throws Exception
	 */
	String getUserid(String code) throws Exception;


	/**
	 * @param code 用户授权的临时授权码code，只能使用一次
	 * @return
	 * @throws Exception
	 */
	OapiSnsGetuserinfoBycodeResponse.UserInfo getUserInfoByCode(String code) throws Exception;


	/**
	 * 扫码登录获取token
	 *
	 * @param appid
	 * @param appSerect
	 * @return
	 * @throws Exception
	 */
	String getAuthToken(String appid, String appSerect) throws Exception;


	/**
	 * 根据token获取永久授权码
	 *
	 * @param accessToken TOKEN
	 * @return
	 * @throws Exception
	 */
	String getPersistentCode(String accessToken) throws Exception;

	/**
	 * 获取用户授权的SNS_TOKEN
	 *
	 * @param accessToken
	 * @param openId
	 * @param persistentCode
	 * @return
	 * @throws Exception
	 */
	String getSnsToken(String accessToken, String openId, String persistentCode) throws Exception;

}
